/*
	Copyright 2008 Jay Elliott

	This file is part of libemath.

	libemath is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	libemath is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with libemath.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "cPoint3d.h"



float& emath::cPoint3d::operator[](unsigned index)
{
	switch (index)
	{
		case 0:
			return x;
		case 1:
			return y;
		case 2:
			return z;
		case 3:
			return w;
	}

	fprintf(stderr, "Warning:  trying to access index %d of a cPoint3d!  Returning reference to index zero instead...\n", index);

	return x;
}


bool emath::cPoint3d::operator==(const cPoint3d& other) const
{
#if 0
	if (x >= other.x - EPSILON && x <= other.x + EPSILON &&
		y >= other.y - EPSILON && y <= other.y + EPSILON &&
		z >= other.z - EPSILON && z <= other.z + EPSILON)
			return true;
	return false;
#endif

	if (equals(x, other.x) && equals(y, other.y) && equals(z, other.z))
		return true;
	return false;
}
